<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2020/11/23
  Time: 15:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="layui/css/layui.css">
</head>
<body>

    <button class="layui-btn test" lay-data="{url: 'uploadImage'}" id="uploadImages">上传图片</button>
    <button class="layui-btn test" lay-data="{url: 'uploadFiles', accept: 'file'}" id="uploadFiles">上传文件</button>

    <script type="text/javascript" src="layui/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="layui/layui.js"></script>
    <script type="text/javascript">
        layui.use(['upload','layer'],function (){
            var upload = layui.upload;
            var layer = layui.layer;
            //创建上传组件
            //图片上传
            upload.render({
                elem:'#uploadImages'
                ,size:0
                ,multiple:true
                ,done:function (res){
                    if (res.code===0){
                        console.log(res.fileName);
                    }
                }
                ,error:function (){
                    //请求异常回调
                    layer.msg("数据请求异常")
                }
            });
            //文件上传
            upload.render({
                elem:'uploadFiles'
                ,size: 0
                ,multiple: true
                ,done:function (res){
                    console.log(res);
                }
                ,error:function (){
                    layer.msg("请求异常")
                }
            });




        });


    </script>

</body>
</html>
